<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>网站后台管理系统HTML模板--模板之家 www.cssmoban.com</title>
<link href="__static__/admin/css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="__static__/admin/js/jquery.js"></script>

<script type="text/javascript">
$(document).ready(function(){
    $(".click").click(function(){
        $(".tip").fadeIn(200);
    });
    
    $(".tiptop a").click(function(){
        $(".tip").fadeOut(200);
    });

    $(".sure").click(function(){
        var d = {};
        var t = $('#MenuInfo').serializeArray();
        $.each(t, function() {
            d[this.name] = this.value;
        });
        console.log(t)
        if(d.Name=='' || d.Ctrl=='' || d.Alt=='' || d.Pid=='') 
        return alert('请录入完整信息');
        $.post('{:url("addTopicInfo")}',{data:d},function(res){
            alert(res.msg)
            if(res.code == 1){
                window.location.reload();
                //$(".tip").fadeOut(100);
            }
        })
        $(".tip").fadeOut(100);
    });

    $(".cancel").click(function(){
        $(".tip").fadeOut(100);
    });

});
</script>


</head>


<body>

	<div class="place">
    <span>位置：</span>
    <ul class="placeul">
    <li><a href="#">首页</a></li>
    <li><a href="#">数据表</a></li>
    <li><a href="#">基本内容</a></li>
    </ul>
    </div>
    
    <div class="rightinfo">
    
    <div class="tools">
    
    	<ul class="toolbar">
        <li class="click"><span><img src="__static__/admin/images/t01.png" /></span>添加</li>
        <!--<li class="click"><span><img src="__static__/admin/images/t02.png" /></span>修改</li>
        <li><span><img src="__static__/admin/images/t03.png" /></span>删除</li>
        <li><span><img src="__static__/admin/images/t04.png" /></span>统计</li>-->
        </ul>
        
        
        <ul class="toolbar1">
        <li><span><img src="__static__/admin/images/t05.png" /></span>设置</li>
        </ul>
    
    </div>
    
    
    <table class="tablelist">
    	<thead>
    	<tr>
            <th>题目<i class="sort"><img src="__static__/admin/images/px.gif" /></i></th>
            <th>选项</th>
            <th>更换答案</th>
            <th>分数</th>
            <th>是否审核</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        {foreach $topic_list as $v}
        <tr>
            <td>
                <textarea style="width: 100%">
                {$v.Subject}
                </textarea>
            </td>                  
            <td>
                <dl>
                    {foreach $v.Option as $o=>$t}
                        <dd>
                            【{$o}】：{$t.value}
                        </dd>
                    {/foreach}
                </dl>
            </td>
            <td>
                 <select name="Answer">
                    {foreach $v.Option as $o=>$t}
                        <option {if $o EQ $t.key} select {/if} value="{$t.key}">
                           【{$o}】：{$t.value}
                        </option>
                    {/foreach}
                 </select>
            </td>
            <td><input type="number" min="0" value="{$v.Fraction}"/></td>
            <td>{$v.State|getAllToexamine}</td>
            <td>
                <a href="javascript:;editTopicInfo({$v.id})" class="tablelink">修改</a>  
                <a href="javascript:;toexamineTopic({$v.id},{$v.State})" class="tablelink">审核</a>    
                <a href="javascript:;deleteTopic({$v.id})" class="tablelink"> 删除</a>
            </td>
        </tr> 
        {/foreach}
        </tbody>
    </table>  
    </div>

    <script type="text/javascript">
    function deleteTopic(id){
        if(!confirm('确认删除此数据？')) return false;
        $.post('{:url("deleteTopic")}',{id:id},function(res){
            console.log('返回数据',res)
            alert(res.msg)
            if(res.code) window.location.reload();
        })
    }
    function toexamineTopic(id,sta){
        $.post('{:url("toexamineTopic")}',{id:id,sta:sta},function(res){
            console.log('返回数据',res)
            alert(res.msg)
            if(res.code) window.location.reload();
        })
    }
    function editTopicInfo(id){
        var nme = $('#MenuName'+id).val();
        var sto = $('#TopicSort'+id).val();
        var sup = $('#MenuSuperior'+id).val();
        var ctrl = $('#MenuCtrl'+id).val();
        var alt = $('#MenuAlt'+id).val();
        if(nme=='' || ctrl=='' || alt=='') return alert('名称/Ctrl/Alt不能为空');
        $.post('{:url("editTopicInfo")}',{id:id,nme:nme,sto:sto,sup:sup,ctrl:ctrl,alt:alt},function(res){
            console.log('返回数据',res)
            alert(res.msg)
            if(res.code) window.location.reload();
        })
    }
	</script>
</body>
</html>

